const express = require('express');
const router = express.Router();

router.get('/me', (req, res) => {
    res.json({
        payload: {
            id: '1001',
            name: '张三',
            username: 'sam',
            enterpriseName: '奇瑞销售股份有限公司',
            roles: ['销售顾问']
        }
    });
});

const codeMap = {
    'dcs-sales-manucturerProductCategory': ['update', 'add', 'abandon', 'maintain'],
    'dcs-sales-carrier': ['add', 'update', 'abandon', 'export'],
    'dcs-sales-dutyUnit': ['add', 'update', 'abandon'],
    'dcs-sales-dealerSaleInformation': ['update', 'abandon'],
    'dcs-sales-annualSalesTarget': ['import', 'export', 'abandon', 'submit', 'approve'],
    'dcs-sales-documentSubmitRule': ['import', 'export', 'add', 'update', 'abandon'],
    'dcs-sales-saleProformaInvoice': ['add', 'update', 'abandon', 'cancel', 'confirm', 'exportExcel', 'exportPdf'],
    'dcs-sales-productCategory': ['add', 'update', 'abandon'],
    'dcs-sales-bank': ['add', 'update', 'abandon'],
    'dcs-sales-saleProformaInvoiceKd': ['add', 'update', 'abandon', 'cancel', 'confirm', 'confirmPi', 'exportExcel', 'exportPdf'],
    'dcs-sales-letterOfCredit': ['add', 'update', 'close', 'approve', 'submit', 'import', 'export', 'receive', 'financeApprove'],
    'dcs-sales-CBUSaleOrder': ['add', 'update', 'submit', 'approve', 'cancel', 'export', 'abandon', 'operationDepartmentApprove', 'generalManagerApprove'],
    'dcs-sales-customsClearance': ['declare', 'clearancet'],
    'dcs-sales-salePlanOrder': ['add', 'update', 'approve', 'submit', 'export', 'abandon', 'import'],
    'dcs-sales-vehicleInformation': ['export', 'exportDetail', 'importKd', 'importDealer'],
    'dcs-sales-KDSaleOrder': ['add', 'update', 'submit', 'approve', 'cancel', 'export', 'abandon', 'operationDepartmentApprove', 'generalManagerApprove'],
    'dcs-sales-salePackingList': ['update', 'close', 'import', 'KdImport'],
    'dcs-sales-saleOrderForecastOrder': ['export'],
    'dcs-sales-vehicleArchives': ['update', 'import', 'export'],
    'dcs-sales-commerceInvoice': ['add', 'update', 'export', 'abandon', 'confirm'],
    'dcs-sales-saleConfirmationKd': ['add', 'update', 'abandon', 'submit', 'approve', 'export'],
    'dcs-sales-KDSaleShipment': ['update', 'export', 'abandon', 'add', 'signned', 'dateSupplement'],
    'dcs-sales-CBUSaleTransport': ['update', 'abandon', 'import'],
    'dcs-sales-KDSaleTransport': ['update', 'abandon', 'import'],
    'dcs-sales-saleDeliveryOrder': ['export'],
    'dcs-sales-CBUSaleShipment': ['update', 'import', 'export', 'abandon', 'add', 'signned', 'dateSupplement'],
    'dcs-sales-pdiOrder': ['add', 'update', 'abandon', 'approve', 'export', 'import'],
    'dcs-sales-pdiOrderDeparture': ['add', 'update', 'abandon', 'approve', 'export', 'import'],
    'dcs-sales-saleConfirmationCbu': ['add', 'update', 'abandon', 'submit', 'approve', 'export'],
    'dcs-sales-potentialCustomer': ['import', 'export', 'abandon'],
    'dcs-sales-salesLead': ['abandon', 'import', 'export'],
    'dcs-sales-kdClaim': ['add', 'update', 'abandon', 'submit', 'approve', 'firstapprove', 'export', 'partclaim', 'reason', 'upgrade', 'laborhourclaim'],
    'dcs-sales-testDrive': ['import', 'export', 'effective', 'update', 'abandon'],
    'dcs-sales-salesInformation': ['import', 'export'],
    'dcs-sales-vehicleFollowList': ['add', 'update', 'export'],
    'dcs-sales-marketingActivity': ['add', 'update', 'export', 'abandon', 'submit', 'approve', 'upload', 'approveReport', 'approveFee', 'register', 'exportExcel', 'exportPdf'],
    'dcs-sales-salePlan': ['export', 'abandon', 'submit', 'import'],
    'dcs-sales-dealerResourceList': ['export', 'update', 'storeSaleRatioImport'],
    'dcs-sales-purchaseSaleInventory': ['import', 'export', 'abandon', 'takeEffect', 'salePlanOrder', 'batchSalePlanOrder', 'batchAbandon', 'batchEffective'],
    'dcs-sales-subPi': ['add', 'update', 'abandon', 'cancel', 'confirm', 'exportExcel', 'exportPdf'],
    'dcs-sales-salesTarget': ['update', 'abandon'],
    'dcs-sales-kdProductionPlan': ['update', 'abandon', 'export', 'import'],
};

router.get('/me/pages/:code', (req, res) => {
    const {
        code
    } = req.params;
    let payload = ['add', 'update', 'disable'];
    if(codeMap[code]) payload = codeMap[code];
    res.json({
        payload
    });
});

module.exports = router;
